﻿using System;
using System.Collections.Generic;
using System.Text;
using jade.content.onto;
using jade.content.schema;
using log4net;

namespace Agents.ontology
{
    public class CalculatorOntology : Ontology
    {

        private static readonly ILog log = LogManager.GetLogger(typeof(CalculatorOntology));
        /**
         * the name of ontology
         **/
        public static String ONTOLOGY_NAME = "CalculatorOntology";

        /**
         * vocabulary
         **/
        public static String CALCULATOR_RESULT = "CalculatorResult";
        public static String NUMBER_A = "a";
        public static String NUMBER_B = "b";
        public static String NUMBER_RESULT = "result";

        public static String SUM = "Sum";
        public static String MULTIPLY = "Multiply";



        private static Ontology theInstance = new CalculatorOntology();

        public static Ontology getInstance()
        {
            return theInstance;
        }

        public CalculatorOntology():base(ONTOLOGY_NAME, BasicOntology.getInstance())
        {

            try
            {
                
                add(new AgentActionSchema(SUM), java.lang.Class.forName("Agents.ontology." + SUM));
                add(new AgentActionSchema(MULTIPLY), java.lang.Class.forName("Agents.ontology." + MULTIPLY));
                add(new ConceptSchema(CALCULATOR_RESULT), java.lang.Class.forName("Agents.ontology." + CALCULATOR_RESULT));

                ConceptSchema result = (ConceptSchema)getSchema(CALCULATOR_RESULT);
                result.add(NUMBER_RESULT, (PrimitiveSchema)getSchema(BasicOntology.INTEGER));

                AgentActionSchema multiply = (AgentActionSchema)getSchema(MULTIPLY);
                multiply.add(NUMBER_A, (PrimitiveSchema)getSchema(BasicOntology.INTEGER));
                multiply.add(NUMBER_B, (PrimitiveSchema)getSchema(BasicOntology.INTEGER));
                multiply.setResult((ConceptSchema)getSchema(CALCULATOR_RESULT));

                AgentActionSchema sum = (AgentActionSchema)getSchema(SUM);
                sum.add(NUMBER_A, (PrimitiveSchema)getSchema(BasicOntology.INTEGER));
                sum.add(NUMBER_B, (PrimitiveSchema)getSchema(BasicOntology.INTEGER));
                sum.setResult((ConceptSchema)getSchema(CALCULATOR_RESULT));

            }
            catch (Exception e)
            {         
                log.Error(e);
                throw e;
            }
        }



    }
}
